<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<HEAD>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<TITLE>清算明细</TITLE>
	<script language="javascript" src="../script/common.js"></script>
	<script language="javascript" src="../script/common_stat.js"></script>
	<script language="javascript" src="../script/card.js" type="text/javascript"></script>
	<!--动态js-->
	<script language="javascript">
		var output;
		function load(){
			//newPivot();
			output = $('outputText');
			setPages(["queryView","pivotTable","flashContent"]);
			//test();
		}
		
		var callback = function(s){
			if (s){
				var x = output.innerText;
				//TX.Test.alertAll(s)
				output.innerText = (x?(x+'\n'):'')+ s;
			}
		}
		function callClearing(v){
			var x;
			if (v=="date")
				x = 2;
			else if (v=="hour")
				x = 3;
			else if (v=="minute")
				x = 4;
			var times = prompt("请输入任务执行的次数:",1);
			if (times){
				var s = DWR.call("clearingService.doManualClearing",x,times);
			}
		}
		
		function deleteClearing(v){
			if (!confirm('确认删除?'))
				return;
			DWR.call("clearingService.doDelete",callback);
		}
		
		
		var o1 = [["总部,现金","充值额",2500],["总部,银行卡","充值额",500],["总部,支票","充值额",900]];
		var o3 = [["广州",1,500],["广州",2,2500],["广州",3,1000],
					["上海",1,2500],["上海",2,500],["上海",3,900],
					["北京",1,1500],["北京",2,1600],["北京",3,1900]
				 ]
		function show2dPie(){
			var chart = new Chart2DPie();
			chart.setData(o3);
			chart.setName("充值图表-js");
			chart.setSubName("支付方式");
			chart.setAttribute("header@names","支付类型-js");
			chart.show();
		}
		function show3dColumn(){
			var chart = new ChartStacked3DColumn();
			chart.setAndShow(o3);
			switchPage("flashContent");
		}
		function show2dColumn(){
			var chart = new Chart2DColumn();
			chart.setAndShow(o3);
			switchPage("flashContent");
		}
		function showFusionCharts2dColumn(){
//			var chart = new FusionCharts("../swf/FCF_Column2D.swf", "myChartId", "700", "400");
//	        var xml = "<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' decimalPrecision='0' formatNumberScale='0'>"
//				+"<set name='Jan' value='462' color='AFD8F8' /><set name='Feb' value='857' color='F6BD0F' /><set name='Mar' value='671' color='8BBA00' /></graph>";
//			//chart.setDataURL("../swf/FCF_Column2D.xml");
//			chart.setDataXML(xml);
//	        chart.render("flashContent");
			var chart = new FusionCharts2DColumn();
			chart.setAndShow(o1);
			switchPage("flashContent");
		}
		function showFusionCharts2dPie(){
			var chart = new FusionChart2DPie();
			chart.setSingleData(o1);
			chart.setAttribute("graph@caption",o1[0][1]);
			chart.show();
			switchPage("flashContent");
		}
		function testDWR(){
			DWR.call("resultsService.getChartData",Common.getValues(statForm),function(v){
				//var chart = new ChartStacked3DColumn();
				var chart = new Chart2DPie();
				if(chart.flag)
					chart.setAndShow(v);
				},
				{blockScreen:true});
		}
		
		var obj = {columnLayouts:[[1],[-1]],columnSize:1,columnTitles:[['正常'],[null]],dataMatrix:[[['361.00','361.00'],['361.00','361.00'],['361.00','361.00'],['361.00','361.00'],['361.00','361.00'],['5.00','5.00'],['5.00','5.00'],['5.00','5.00'],['5.00','5.00'],['5.00','5.00'],['30.00','30.00'],['30.00','30.00'],['30.00','30.00'],['30.00','30.00'],['30.00','30.00'],['396.00','396.00'],['396.00','396.00']],[['3','3'],['3','3'],['3','3'],['3','3'],['3','3'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['1','1'],['5','5'],['5','5']]],dimensions:[{title:'受理机构大区公司'},{name:'accountType',title:'帐户类型'},{name:'tradeType',title:'交易类型'},{name:'cardUserType',title:'客户分类'},{name:'cardUserLevel',title:'客户级别'},{name:'cardType',title:'卡类型'},{name:'tradeStatus',title:'交易状态'},{name:'sum',title:'交易额'},{name:'count',title:'交易数'}],measureInRow:false,measureSize:2,rowLayouts:[[16,5,4,3,2,1],[0,0,0,0,0,-1],[0,0,0,0,-2,0],[0,0,0,-3,0,0],[0,0,-4,0,0,0],[0,5,4,3,2,1],[0,0,0,0,0,-1],[0,0,0,0,-2,0],[0,0,0,-3,0,0],[0,0,-4,0,0,0],[0,5,4,3,2,1],[0,0,0,0,0,-1],[0,0,0,0,-2,0],[0,0,0,-3,0,0],[0,0,-4,0,0,0],[0,-5,0,0,0,0],[-6,0,0,0,0,0]],rowSize:6,rowTitles:[['总部直属','资金','现金充值','','普通客户','普通个人卡'],['总部直属','资金','现金充值','','普通客户',null],['总部直属','资金','现金充值','',null,null],['总部直属','资金','现金充值',null,null,null],['总部直属','资金',null,null,null,null],['总部直属','售卡手续费','现金充值','中客户','银卡客户','普通车队卡'],['总部直属','售卡手续费','现金充值','中客户','银卡客户',null],['总部直属','售卡手续费','现金充值','中客户',null,null],['总部直属','售卡手续费','现金充值',null,null,null],['总部直属','售卡手续费',null,null,null,null],['总部直属','卡押金','现金充值','中客户','银卡客户','普通车队卡'],['总部直属','卡押金','现金充值','中客户','银卡客户',null],['总部直属','卡押金','现金充值','中客户',null,null],['总部直属','卡押金','现金充值',null,null,null],['总部直属','卡押金',null,null,null,null],['总部直属',null,null,null,null,null],[null,null,null,null,null,null]],title:'清算报表'};
		
		function test(){
			DWR.call("clearingService.doDailyClearing",function(v){});
			//DWR.call("dailyCheckService.generateResults","2008-04-01",function(v){});
			return;
			//parseCrossData()
			$('pivotTools').innerHTML = getToolbar()
			var crosstab = new Crosstab();
			crosstab.setData(obj);
			crosstab.show('printArea');
			switchPage("pivotTable");
			//$('pivotTable').style.display="";
			return;
		}
		
		function newPivot(){
			var sql = "operator_stat";
			var crossconf = {};
			crossconf.measures = {"count":"数量"}
			crossconf.defaultMeasure = {count:true};
			crossconf.dimensions = {"registerTime":{name:"时间",option:{"year":"年份","quarter":"季度","month":"月份"}},"org":{name:"所属机构",option:{"p200":"省大区","p500":"地市"}},"status":"状态","gender":"性别"}
			crossconf.defaultVertical = {};
			crossconf.defaultHorizon = {"status":true};
			var pivot = new Pivot('newPivot',sql,crossconf,null,true);
			pivot.setPivotHead('pivotTitle','操作员报表');
			crossconf.defaultHorizon = {"org":{"p200":true}};
			var pivot2 = new Pivot('newPivot2',sql);
			pivot2.ShowZero = true;
			pivot2.initConf(crossconf);
			pivot2.refresh();
		}
		
		
		function parseCrossData(){
			var skipSum = true;
			var rows = obj.rowTitles;
			var columns = obj.columnTitles;
			var data = obj.dataMatrix;
			if (data.length != obj.measureSize){
				showError('数据错误:数据集维度不一致');
			}
			var measure = obj.dimensions.slice(-1*obj.measureSize);
			var chartData = new Array();
			creation:
				for(var i=0;i<rows.length;i++){
					for(var j=0;j<columns.length;j++){
						var x = rows[i].concat(columns[j]);
						if (skipSum)
							for(var t=0;t<x.length;t++)
								if(x[t]==null)
									continue creation;
						var d = x.join();
						for(var k=0;k<measure.length;k++)
							chartData.push([d,measure[k].title,data[k][i][j]]);
					}
				}
//			alert(chartData.length);
//			TX.Test.alertAll(chartData[0]);
			var chart = new FusionCharts2DColumn();
			chart.div = 'printArea';
			chart.setData(chartData);
//			chart.setName("清分报表");
//			chart.setAttribute("header@names","统计项");
//			output.innerText = chart.getXML();
			chart.show();
			//switchPage("flashContent");
		}
		
		function getToolbar() {
			var html = "<table cellpadding='0' cellspacing='1' border='0'>"
				+ "<tr><td><input height='24' width='24' title='打开OLAP导航' border='0' src='../images/pivot/toolbar/cube-up.png' name='toolbar01.cubeNaviButton' type='image'></td>"
				+ "<td><input height='24' width='24' title='显示MDX编辑器' border='0' src='../images/pivot/toolbar/mdx-edit-up.png' name='toolbar01.mdxEditButton' type='image'></td>"
				+ "<td><input height='24' width='24' title='配置OLAP表' border='0' src='../images/pivot/toolbar/sort-asc-up.png' name='toolbar01.sortConfigButton' type='image'></td>"
				+ "<td><div style='width: 1ex'></div></td>"
				+ "<td><input height='24' width='24' title='显示父成员' border='0' src='../images/pivot/toolbar/level-style-up.png' name='toolbar01.levelStyle' type='image'></td>"
				+ "<td><input height='24' width='24' title='隐藏网格' border='0' src='../images/pivot/toolbar/hide-spans-up.png' name='toolbar01.hideSpans' type='image'></td>"
				+ "<td><input height='24' width='24' title='显示属性' border='0' src='../images/pivot/toolbar/properties-up.png' name='toolbar01.propertiesButton' type='image'></td>"
				+ "<td><input height='24' width='24' title='压缩空行/列' border='0' src='../images/pivot/toolbar/non-empty-up.png' name='toolbar01.nonEmpty' type='image'></td>"
				+ "<td><input height='24' width='24' title='交换坐标轴' border='0' src='../images/pivot/toolbar/swap-axes-up.png' name='toolbar01.swapAxes' type='image'></td>"
				+ "<td><div style='width: 1ex'></div></td>"
				+ "<td><input height='24' width='24' title='允许按成员钻取' border='0' src='../images/pivot/toolbar/navi-member-up.png' name='toolbar01.drillMember' type='image'></td>"
				+ "<td><input height='24' width='24' title='允许按位置钻取' border='0' src='../images/pivot/toolbar/navi-position-down.png' name='toolbar01.drillPosition' type='image'></td>"
				+ "<td><input height='24' width='24' title='钻取替代' border='0' src='../images/pivot/toolbar/navi-replace-up.png' name='toolbar01.drillReplace' type='image'></td>"
				+ "<td><input height='24' width='24' title='钻取指标' border='0' src='../images/pivot/toolbar/navi-through-up.png' name='toolbar01.drillThrough01' type='image'></td>"
				+ "<td><div style='width: 1ex'></div></td>"
				+ "<td><input height='24' width='24' title='显示图表' border='0' src='../images/pivot/toolbar/chart-down.png' name='toolbar01.chartButton01' type='image'></td>"
				+ "<td><input height='24' width='24' title='图表配置' border='0' src='../images/pivot/toolbar/chart-config-up.png' name='toolbar01.chartPropertiesButton01' type='image'></td>"
				+ "<td><div style='width: 1ex'></div></td>"
				+ "<td><input height='24' width='24' title='配置打印设置' border='0' src='../images/pivot/toolbar/print-config-up.png' name='toolbar01.printPropertiesButton01' type='image'></td>"
				+ "<td><a href='./Print?cube=01&type=1'><img height='24' width='24' title='导出PDF' border='0' src='../images/pivot/toolbar/print-up.png'></a></td>"
				+ "<td><a href='./Print?cube=01&type=0'><img height='24' width='24' title='导出Excel' border='0' src='../images/pivot/toolbar/excel-up.png'></a></td></tr></table>";
			return html;
		};
	</script>
</HEAD>

<body onload="load();">
	<div id="queryView" class="form">
		<div class="formTitle">
			<script language="JavaScript">
				document.write("本页面文件更新于: "+document.lastModified+" | 本页面仅供测试时使用")
			</script>
		</div>
		<table width="100%" cellspacing="0" cellpadding="4" border="1">
			<tr>
				<td>清算</td>
				<td>
					跨度:
					<button type="button" onclick="callClearing('date');">[天]</button>
					<button type="button" onclick="callClearing('hour');">[小时]</button>
					<button type="button" onclick="callClearing('minute');">[分钟]</button> | 
					<button type="button" onclick="deleteClearing();">[删]</button>
				</td>
				<td width ="450px">
					<label>输出:</label>
					<button type="button" onclick="javascript:output.innerHTML='';">清空</button><br>
				</td>
			</tr>
			<tr>
				<td>历史交易</td>
				<td>
					<button type="button" onclick="DWR.call('historyService.doMoveHistory',callback);">正常交易 -> 历史交易</button><br>
				</td>
				<td rowspan="3">
					<textarea id="outputText" rows="7" cols="60"></textarea>
					
				</td>
			</tr>
			<!--
			<tr>
				<td>AnyChart</td>
				<td>
					<button type="button" onclick="show2dColumn();">2D柱状图</button>
					<button type="button" onclick="show2dPie();">2D饼图</button>
					<br>
					<button type="button" onclick="show3dColumn();">3D柱状分块图</button>
				</td>
			</tr>
			-->
			<tr>
				<td>FusionCharts</td>
				<td>
					<button type="button" onclick="showFusionCharts2dColumn();">2D柱状图</button>
					<button type="button" onclick="showFusionCharts2dPie();">2D饼图</button>
					<!--
					<br>
					<button type="button" onclick="showusionCharts3dColumn();" disabled>3D柱状分块图</button>
					-->
				</td>
			</tr>
			<tr>
				<td>其他</td>
				<td>
					<button type="button" onclick="test();">Test</button>
				</td>
			</tr>
		</table>
		<div id="newPivot"></div><div id="newPivot2"></div>
	</div>
	<div id="flashContent" class="listBorder" style="display:none;" align="center"></div>
	<div id="pivotTable" style="display:none;" align="center">
		<div id="pivotTools">
		</div>
		<div id="printArea">
		</div>
			<p>
				<a href="#" onclick="wangdana()">设置</a>
				|
				<a href="#" onclick="parseCrossData()">柱状图</a>
				|
				<a href="#" onclick="wangdana()">饼状图</a>
				|
				<a href="#" onclick="WebPrint.preview('printArea')">打印预览</a>
				|
				<a href="#" onclick="WebPrint.print('printArea')">打印</a>
				|
				<a href="#" onclick="switchPage('queryView')">返回</a>
			</p>
	</div>
</body>
</HTML>
